package com.panda.order.taobao;

import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.TradesSoldGetRequest;
import com.taobao.api.response.TradesSoldGetResponse;

public class ApiTest {
    // 淘宝订单字段
    private static String fields = "tid,pic_path,payment,seller_rate,post_fee,consign_time,received_payment,order_tax_fee," +
            "num_iid,type,price,discount_fee,total_fee,created,pay_time,modified,end_time,seller_flag,buyer_nick," +
            "has_buyer_message,mark_desc,shipping_type,adjust_fee,trade_from,buyer_rate,delivery_time,collect_time," +
            "dispatch_time,sign_time,delivery_cps,receiver_name,receiver_state,receiver_address,receiver_zip," +
            "receiver_mobile,receiver_phone,receiver_country,receiver_town,receiver_city,receiver_district,orders";

    public static void main(String[] args) throws Exception {
        String serverUrl = "http://gw.api.taobao.com/router/rest";
        String appKey = "32495572"; // 可替换为您的应用的AppKey
        String appSecret = "040d5813e8fca55a9ab3cb7f783af1d3"; // 可替换为您的应用的AppSecret
        String sessionKey = "6101502b621b26ebf954d4023d983f63b7aeef1926aabdf3065052476"; // 必须替换为授权得到的真实有效SessionKey

        TaobaoClient client = new DefaultTaobaoClient(serverUrl, appKey, appSecret);
        TradesSoldGetRequest req = new TradesSoldGetRequest();
        req.setFields(fields);

        TradesSoldGetResponse rsp = client.execute(req, sessionKey);
        System.out.println(rsp.getBody());

    }

}